<template>
  <div>
    <!-- 面包屑导航区域 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>单据管理</el-breadcrumb-item>
      <el-breadcrumb-item>报销单审批</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图区域 -->
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>单据列表</span>
      </div>
      <!-- 搜索区域 -->
      <el-input placeholder="请输入内容" v-model="searchContent">
        <el-select v-model="select" slot="prepend" placeholder="请选择">
          <el-option label="职工姓名" value="employee-name"></el-option>
          <el-option label="家属姓名" value="relative-name"></el-option>
          <el-option label="工作部门" value="department"></el-option>
        </el-select>
        <el-button slot="append" icon="el-icon-search"></el-button>
      </el-input>
      <!-- 用户列表区域-->
      <el-table :data="ticketlist" border stripe
                :header-cell-style="{'text-align':'center'}"
                :cell-style="{'text-align':'center'}">
        <el-table-column type="index" label="序号"></el-table-column>
        <el-table-column prop="employeename" label="职工姓名"></el-table-column>
        <el-table-column prop="department" label="职工部门" ></el-table-column>
        <el-table-column prop="relativename" label="家属姓名"></el-table-column>
        <el-table-column prop="sex" label="性别"></el-table-column>
        <el-table-column prop="age" label="年龄"></el-table-column>
        <el-table-column prop="relation" label="与职工关系"></el-table-column>
        <el-table-column prop="fee" label="医疗费用"></el-table-column>
        <el-table-column prop="shibao" label="上报金额"></el-table-column>
        <el-table-column prop="date" label="上报日期"></el-table-column>
        <el-table-column label="操作" width="150px">
          <template slot-scope="scope">
            <el-button type="primary" size="mini">通过</el-button>
            <el-button type="danger" size="mini">驳回</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页区域 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.nowpage"
        :page-sizes="[1, 2, 5, 10]"
        :page-size="queryInfo.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </el-card>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        // 选择种类
        select: '',
        searchContent: '',
        //票据列表
        ticketlist: [],
        // 总数
        total: 0,
        queryInfo: {
          //当前页数
          nowpage: 1,
          //当前每页显示多少条数据
          pagesize: 10
        }
      }
    },
    created () {
      this.getTicketsNumber()
      this.getTicketsList()
    },
    methods: {
          //获取未审核票据数量
          async getTicketsNumber(){
            let res = await this.$http.get('ticket/count')
            if(res.status !== 200) {
              return this.$message.error('获取审核列表数量失败!')
            }
            this.total=res.data
            console.log(res)
          },
          //获取票据列表
          async getTicketsList () {
            let res = await this.$http.get('ticket',{params:this.queryInfo})
            if(res.status !== 200) {
              return this.$message.error('获取审核列表失败!')
            }
            this.ticketlist=res.data
           // console.log(res)
          },
          // 监听分页尺寸改变的事件
          handleSizeChange(newSize) {
            //console.log(newSize)
            this.queryInfo.pagesize=newSize
            this.getTicketsList()
          },
          //监听当前页码值改变的事件
          handleCurrentChange(nowPage){
           // console.log(nowPage)
            this.queryInfo.nowpage=nowPage
            this.getTicketsList()
          }

    }
  }
</script>
<style lang="less" scoped>
  .el-input {
    width: 700px;
  }
  .el-select {
    width: 120px;
  }
  .input-with-select .el-input-group__prepend {
    background-color: #fff;
  }
  .el-table {
    margin-top: 15px;
    font-size: 12px;
  }
  .el-pagination {
    margin-top: 15px;
  }
</style>
